<?php

function getParam($paramName, $defaultValue)
{
    global $_MODULE;
    $value = $_MODULE[$paramName];
    if (empty($value)) return $defaultValue;
    return $value;
}

function myEcho($paramName, $defaultValue)
{
    echo getParam($paramName, $defaultValue);
}


function getBgImageColor($bgType,$value){
    if('image' == $bgType) return 'background-image: url('.$value.');background-repeat: no-repeat';
    else return 'background-color: '.$value;
}

function hasBack(){
    return "";
}

function getCouponHtml($padding_right,$coupon_link,$bg_image_color,$denomination,$denomination_color,$using_the_quota,$using_the_quota_color,$click_the_text,$click_the_text_color,$hasBack){
    return "
    <td style='$padding_right'>
    <a class='coupon' style='text-decoration: none;display: block;' href='$coupon_link'>
            <div style='$bg_image_color;width: 390px;height: 125px;'>
                <div style='padding-top: 15px;border-bottom: none'>
                    <table style='margin: 0 auto;text-align: center;'>
                        <tr>
                            <td><div class='denomination' style='color: $denomination_color;padding-right: 20px;'>$denomination</div></td>
                            <td><div class='using_the_quota' style='color: $using_the_quota_color;padding-bottom: 10px;'>USD&nbsp;$using_the_quota</div></td>
                        </tr>
                        <tr>
                            <td colspan='2'><div class='click-font' style='color: $click_the_text_color;'>$click_the_text</div></td>
                        </tr>
                    </table>
                    
                </div>
            </div>
            
            
        </a>
    </td>
    ";
}

?>


<div class="module dshop-um-wl-yhq-3 module-thirdparty"
     style='margin-bottom:<? echo $bottom_margin; ?>px; background-color:<? myEcho('bottom_color','#555555')?>;'>
    <table>
        <tr>
            <?php

            for($i=0;$i<3;$i++){
                $padding_right = '';
                if($i != 2) $padding_right = 'padding-right: 15px;';

                $bg_image_color = getParam('bg_image_color_'.$i,'#2981CB');
                $bg_type = getParam('bg_type_'.$i,'color');

                echo getCouponHtml($padding_right,
                    getParam('coupon_link_'.$i,'#'),
                    getBgImageColor($bg_type,$bg_image_color),
                    getParam('denomination_'.$i,'$2.00'),
                    getParam('denomination_color_'.$i,'white'),
                    getParam('using_the_quota_'.$i,'$100'),
                    getParam('using_the_quota_color_'.$i,'white'),
                    getParam('click_the_text_'.$i,'RECEIVE IT'),
                    getParam('click_the_text_color_'.$i,'white'),hasBack());
            }

            ?>
        </tr>
    </table>


</div>
